<?php

/**
 * This is the model class for table "lusi_resources".
 *
 * The followings are the available columns in table 'lusi_resources':
 * @property string $id
 * @property string $course_id
 * @property string $resource_name
 * @property string $resource_file_location
 * @property string $created_by
 * @property string $created_date
 * @property string $updated_by
 * @property string $updated_date
 * @property integer $status
 * @property string $file_type
 * @property string $file_size
 * @property string $file_name
 * @property string $description
 *
 * The followings are the available model relations:
 * @property Courses $course
 */
class Resources extends CActiveRecord
{
	/**
	 * @var string
	 */
	public $id;

	/**
	 * @var string
	 */
	public $course_id;

	/**
	 * @var string
	 */
	public $resource_name;

	/**
	 * @var string
	 */
	public $resource_file_location;

	/**
	 * @var string
	 */
	public $created_by;

	/**
	 * @var string
	 */
	public $created_date;

	/**
	 * @var string
	 */
	public $updated_by;

	/**
	 * @var string
	 */
	public $updated_date;

	/**
	 * @var integer
	 */
	public $status;

	/**
	 * @var string
	 */
	public $file_type;

	/**
	 * @var string
	 */
	public $file_size;

	/**
	 * @var string
	 */
	public $file_name;

	/**
	 * @var string
	 */
	public $description;


 	/**
	 * @var Courses
	 */
	 public $Courses;

	/**
	 * Returns the static model of the specified AR class.
	 * @return Resources the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'lusi_resources';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('course_id, resource_name, resource_file_location, created_by, created_date', 'required'),
			array('status', 'numerical', 'integerOnly'=>true),
			array('course_id', 'length', 'max'=>11),
			array('resource_name, created_by, updated_by, file_name', 'length', 'max'=>100),
			array('resource_file_location', 'file', 'allowEmpty' => false),
			array('file_type, file_size', 'length', 'max'=>50),
			array('updated_date, description', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, course_id, resource_name, resource_file_location, created_by, created_date, updated_by, updated_date, status, file_type, file_size, file_name, description', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'course' => array(self::BELONGS_TO, 'Courses', 'course_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'course_id' => 'Course',
			'resource_name' => 'Resource Name',
			'resource_file_location' => 'Resource File Location',
			'created_by' => 'Created By',
			'created_date' => 'Created Date',
			'updated_by' => 'Updated By',
			'updated_date' => 'Updated Date',
			'status' => 'Status',
			'file_type' => 'File Type',
			'file_size' => 'File Size',
			'file_name' => 'File Name',
			'description' => 'Description',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('course_id',$this->course_id,true);
		$criteria->compare('resource_name',$this->resource_name,true);
		$criteria->compare('resource_file_location',$this->resource_file_location,true);
		$criteria->compare('created_by',$this->created_by,true);
		$criteria->compare('created_date',$this->created_date,true);
		$criteria->compare('updated_by',$this->updated_by,true);
		$criteria->compare('updated_date',$this->updated_date,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('file_type',$this->file_type,true);
		$criteria->compare('file_size',$this->file_size,true);
		$criteria->compare('file_name',$this->file_name,true);
		$criteria->compare('description',$this->description,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}